package com.ruoyi.web.controller.clue;

import javax.servlet.http.HttpServletResponse;

import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ClueCustomer;
import com.ruoyi.system.domain.vo.ClueCustomerVO;
import com.ruoyi.system.service.IClueCustomerService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索客户Controller
 * 
 * @author luojiqiang
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/clue/customer")
public class ClueCustomerController extends BaseController
{
    @Autowired
    private IClueCustomerService clueCustomerService;

    /**
     * 查询线索客户列表
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClueCustomer clueCustomer)
    {
        startPage();
        List<ClueCustomerVO> list = clueCustomerService.selectClueCustomerList(clueCustomer);
        return getDataTable(list);
    }

    /**
     * 导出线索客户列表
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:export')")
    @Log(title = "线索客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClueCustomer clueCustomer)
    {
        List<ClueCustomerVO> list = clueCustomerService.selectClueCustomerList(clueCustomer);
        ExcelUtil<ClueCustomerVO> util = new ExcelUtil<ClueCustomerVO>(ClueCustomerVO.class);
        util.exportExcel(response, list, "线索客户数据");
    }

    /**
     * 获取线索客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(clueCustomerService.selectClueCustomerById(id));
    }

    /**
     * 新增线索客户
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:add')")
    @Log(title = "线索客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClueCustomer clueCustomer)
    {
        return toAjax(clueCustomerService.insertClueCustomer(clueCustomer));
    }

    /**
     * 修改线索客户
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:edit')")
    @Log(title = "线索客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClueCustomer clueCustomer)
    {
        return toAjax(clueCustomerService.updateClueCustomer(clueCustomer));
    }

    /**
     * 删除线索客户
     */
    @PreAuthorize("@ss.hasPermi('clue:customer:remove')")
    @Log(title = "线索客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clueCustomerService.deleteClueCustomerByIds(ids));
    }
}
